Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync achievement title/description/badge to active event achievements #3181

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Jamiras
Copy link
Member

@Jamiras Jamiras commented Feb 6, 2025

Copy link
Member

@wescopeland wescopeland Feb 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionally the code works great. My only concern is everything within the conditionals is duplicative. Seems like it would be easy to change it in one place and forget to change it in the other.

I'm wondering if it'd be best to extract it to either a method on the model or an action, eg:

if ($record->isDirty(['BadgeName', 'Title', 'Description'])) {
    /**
     * reusable code
     * $record->syncMetadataWithEventAchievements()?
     * (new SyncMetadataWithEventAchievementsAction())->execute(...)?
     */
}
$shouldResyncEventAchievementMetadata = (
    in_array('badge', $fields)
    || in_array('title', $fields)
    || in_array('description', $fields)
);
if ($shouldResyncEventAchievementMetadata) {
    /**
     * reusable code
     * $record->syncMetadataWithEventAchievements()?
     * (new SyncMetadataWithEventAchievementsAction())->execute(...)?
     */
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants